<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改用户信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>

    <script language="JavaScript" type="text/javascript">
        //判断规则（正则表达式）
        function goto() {
            var name = document.getElementById("username");
            var pwd = document.getElementById("userpassword");


            var telephone = document.getElementById("userphone");
            var email = document.getElementById("useremail");
            if (name.value.trim().length < 2) {
                alert("用户名长度须大于2位");
                name.focus()
                name.value = "";
                return;
            }
//       规则必须包括大小写字母，数字
            var regex = /^(?!(?:\d+|[a-zA-Z]+|[\da-z]+|[\dA-Z])$)[\da-zA-Z]{6,}$/;
//        var regex = /^[A-z0-9]{10,20}$/;
            if (!pwd.value.match(regex)) {
                alert("密码不符合规定");
                pwd.focus()
                pwd.value = "";
                return;
            }


            var regex3 = /^1[3,5,7,8]\d{9}$/;
            if (!regex3.test(telephone.value)) {
                alert("手机号码不符合规定");
                telephone.focus()
                telephone.value = "";
                return;
            }
            //test方法必须用反斜杠转义
            var regex4 = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if (!regex4.test(email.value)) {
                alert("邮箱不符合规定");
                email.focus()
                email.value = "";
                return;
            }
        }
    </script>

</head>
<body>
<!-- 顶部开始 -->
<div th:replace="common::#topbar"></div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 左侧菜单开始 -->
    <div th:replace="common::#leftbar"></div>
    <!-- 左侧菜单结束 -->
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->

            <fieldset class="layui-elem-field layui-field-title site-title">
                <legend><a name="default">修改个人信息</a></legend>
            </fieldset>
            <form class="layui-form" th:action="@{/doupdate-user}" method="post">
                <div class="layui-form-item">
                    <label for="useraccount" class="layui-form-label">
                        <span class="x-red"></span>账户
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="useraccount" disabled="disabled" name="useraccount" required=""
                               lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.useraccount}">
                    </div>

                    <label for="username" class="layui-form-label">
                        <span class="x-red"></span>用户名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="username" disabled="disabled" name="username" required=""
                               lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.username}" placeholder="长度大于2位">
                    </div>

                </div>

                <div class="layui-form-item">
                    <label for="usergender" class="layui-form-label">
                        <span class="x-red"></span>性别
                    </label>
                    <div class="layui-input-inline">
                        <select id="usergender" name="usergender" class="form-control">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>

                    <label for="useremail" class="layui-form-label">
                        <span class="x-red"></span>用户邮箱
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="useremail" name="useremail" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.useremail}" placeholder="邮箱格式">
                    </div>

                </div>

                <div class="layui-form-item">
                    <label for="userphone" class="layui-form-label">
                        <span class="x-red"></span>电话
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userphone" name="userphone" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.userphone}" placeholder="11位整数">
                    </div>

                    <label for="userpassword" class="layui-form-label">
                        <span class="x-red"></span>账户密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="userpassword" name="userpassword" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.userpassword}"
                               placeholder="长度大于十位，包含大小写字母和数字">
                    </div>

                </div>


                <div class="layui-form-item">

                    <div class="layui-input-inline">
                        <input type="hidden" id="id" name="id" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.id}">
                    </div>
                    <div class="layui-input-inline">
                        <input type="hidden" id="userunit" name="userunit" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.userunit}">
                    </div>


                </div>

                <div class="layui-form-item">

                    <div class="layui-input-inline">
                        <input type="hidden" id="usertype" name="usertype" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.usertype}">
                    </div>
                    <div class="layui-input-inline">
                        <input type="hidden" id="cpid" name="cpid" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${user.cpid}">
                    </div>


                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                    </label>
                    <input type="submit" name="修改" onclick="goto()" class="layui-btn">
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
<!-- 底部开始 -->
<div th:replace="common::#bottombar"></div>
<!-- 底部结束 -->
<!-- 背景切换开始 -->
<div th:replace="common::#backbar"></div>
<!-- 背景切换结束 -->
</body>
</html>